<template>
  <h2>模板引用</h2>
  <input type="text" ref="ipt" />
  <button @click="fn">btn</button>
</template>

<script>
import { ref, onMounted } from "vue";
export default {
  setup() {
    const ipt = ref(null);

    // onMounted(() => {
    //   input.value.focus();
    // });

    const fn = () => {
      // console.log(this.$refs.ipt);
      console.log(ipt.value);
      // ipt.value.focus();
    };

    return { ipt, fn };
  },
};
</script>
